package com.chenfan.mcn.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chenfan.mcn.extension.Res;
import com.chenfan.mcn.model.DiscountApproval;
import com.chenfan.mcn.model.McnPage;
import com.chenfan.mcn.model.dto.ApprovalConditionallyDTO;
import com.chenfan.mcn.model.dto.DiscountDTO;
import com.chenfan.mcn.model.dto.DiscountApprovalSearchDTO;
import com.chenfan.mcn.model.vo.DiscountApprovalRelationVO;
import com.chenfan.mcn.model.vo.DiscountApprovalVO;
import com.chenfan.mcn.model.vo.DiscountInfoVO;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 折扣审批单 服务类
 * </p>
 *
 * @author lizhejin
 * @since 2021-01-07
 */
public interface DiscountApprovalService extends IService<DiscountApproval> {

    /**
     * 折扣审批单 分页数据
     *
     * @param page 分页信息
     * @param dto  过滤条件
     * @return
     */
    Page<DiscountApprovalVO> getDiscountApprovalList(McnPage<DiscountApprovalVO> page, DiscountApprovalSearchDTO dto);

    /**
     * 保存折扣审批单
     *
     * @param dto {@link DiscountDTO}
     * @return boolean
     */
    Long saveDiscount(DiscountDTO dto);

    /**
     * 修改折扣审批单状态
     *
     * @param discountApproval {@link DiscountApproval}
     * @return {@link Res}
     */
    boolean changeStatus(DiscountApproval discountApproval);

    /**
     * 获取折扣审批单详情
     *
     * @param id 折扣审批单id
     * @return {@link DiscountDTO}
     */
    DiscountInfoVO getDiscountApprovalInfo(Long id);

    /**
     * 获取有效期内的数量
     *
     * @param dto {@link DiscountDTO}
     * @return int
     */
    int checkYearActiveCounts(DiscountDTO dto);

    /**
     * 匹配是否有对应审批单并回显
     *
     * @param approvalConditionallyDTO
     * @return DiscountInfoVO
     */
    List<DiscountInfoVO> getApprovalConditionally(ApprovalConditionallyDTO approvalConditionallyDTO);

    /**
     * 年度优惠含平台返点、仅年度优惠：所有合同的商务确认合同金额的总合
     *
     * @param customerId
     * @param discountId
     * @return BigDecimal
     */
    BigDecimal getWithYearAmount(Long customerId, Long discountId);

    /**
     * 年度优惠不含平台返点：合同类型是“散单-形式合同或者年度优惠-形式合同”的所有合同的商务确认合同金额的总合
     *
     * @param customerId
     * @param discountId
     * @return BigDecimal
     */
    BigDecimal getWithNoYearAmount(Long customerId, Long discountId);

    /**
     * 根据客户名称获取折扣返点审批单号(所有类型是【年度优惠】的折扣返点审批单，且状态是审核通过。)
     *
     * @param customerId {@link Long}
     * @return {@link List}
     */
    List<String> getDisCountApprovalCode(Long customerId);

    /**
     * 客户档案关联折扣审批单
     *
     * @param page
     * @param customerId
     * @return
     */
    Page<DiscountApprovalRelationVO> getDiscountApprovalRelationList(McnPage<DiscountApprovalRelationVO> page, Long customerId);

    /**
     * 通过返点合同编号获取详情
     * @param discountCode
     * @return
     */
    DiscountApproval getByCode(String discountCode);
}
